<?php declare(strict_types=1);


namespace App\Api\V2\Controller\Vbill;


use App\Api\Controllers\BaseController;
use App\Api\Controllers\Config\VbillConfigController;
use App\Services\Vbill\AuthenticationService;
use App\Traits\ResponseTrait;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;

class AuthenticationController extends BaseController
{

    use ResponseTrait;

    public function certification(Request $request)
    {
        $store_id = $request->input("store_id");
        try {
            $service = new AuthenticationService();
            list($bool, $msg) = $service->certification($store_id);
            return $this->successResponse("ok", $bool);
        } catch (\Exception $e) {
            return $this->errorResponse($e->getMessage());
        }
    }

    public function queryApplyInfo(Request $request)
    {
        $store_id = $request->input("store_id");
        try {
            $service = new AuthenticationService();
            list($bool, $msg) = $service->certification($store_id);
            $result = $service->queryApplyInfo($store_id, $bool, (string)$msg);
            return $this->successResponse("ok", ["data" => $result]);
        } catch (\Exception $e) {
            return $this->errorResponse($e->getMessage() . $e->getLine());
        }
    }

    public function backApplyBill(Request $request)
    {
        $store_id = $request->input("store_id");
        try {
            $service = new AuthenticationService();
            $result = $service->backApplyBill($store_id);
            return $this->successResponse("ok", $result);
        } catch (\Exception $e) {
            return $this->errorResponse($e->getMessage());
        }
    }


}